<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
     

    <script>

        // let cookie = "_ga=GA1.2.1075013144.1614756613; ttcid=9fd994623cb8467db871f0373fef1dbb19; _tea_utm_cache_2608={%22utm_source%22:%2220210802%22%2C%22utm_medium%22:%22Webnewsfeed%22%2C%22utm_campaign%22:%2231day%22}; MONITOR_WEB_ID=b2f888d9-a0d4-4f4a-917c-5bba2e58b08f; passport_csrf_token_default=5df44cff291f41d791548f47b484ded4; passport_csrf_token=5df44cff291f41d791548f47b484ded4; _gid=GA1.2.968280915.1630578319; tt_scid=W0cONi6LaNh8nquib9YT9SpgzhBrpOkfGVQ-YdZ8HiPbSaJTx0Fu37b84h6GZzcyca1c";
        
        // cookie = '{"' + cookie + '"}';
        // cookie = cookie.replace(/=/g,'":"');
        // cookie = cookie.replace(/;/g,'","');
        // console.log(cookie);
        // let jsonCookie = JSON.parse(cookie);
        // console.log(jsonCookie);

        const cookieObj = {};
        const cookieStr = '_ga=GA1.2.202382987.1605787358; ttcid=9f48283093684b4abb5d4907bd7fe80f17; passport_csrf_token_default=c1b33ec43273771c41849e7cabae2756; passport_csrf_token=c1b33ec43273771c41849e7cabae2756; MONITOR_WEB_ID=f5be05b4-4168-4ed6-9d82-9859df9dc30e; _gid=GA1.2.2102805136.1630581198; tt_scid=AoIyLxoDXUJ7cqWjlnJ3WmfuT.I4vV6rS7fApdFJ-p7358reFLZcIuBSzRc-xW0Jff69'
        const parseCookie = str =>
        str
            .split(';')
            // 变形的
            .map(v => v.split("="));
            // 二位数组 编程一个{} 把数组推平的方法, 
            
        const arr = parseCookie(cookieStr);
        console.log(arr);

        const obj = arr.reduce((acc, v) => { 
            acc[v[0]] = v[1]
            return acc
            }  , {});

        console.log(arr);
        console.log(obj);


            

    </script>
</body>
</html>
